package com.icreate.storm.methods.indicators.fieldCreater;

/**
 * Created by yc on 2017/5/22.
 */
public abstract class BaseSubstring {
//    protected int splitIndexes[];
    private String s;
    protected abstract int[] getIndexBuffer();
    protected String getCell(int index){
        return s.substring(getIndex(index-1)+1,getIndex(index));
    }
    private int getIndex(int i){
        return getIndexBuffer()[i];
    }
    protected void setSplitIndexes(String s){
        int splitIndexes[]= getIndexBuffer();
        this.s=s;
        for (int i = 0; i < splitIndexes.length; i++) {
            if(i==0)
                splitIndexes[i]= s.indexOf(",");
            else splitIndexes[i]=s.indexOf(",",splitIndexes[i-1]+1);
        }
    }
}
